package com.movies.service.config;

import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;


@Component
public class SaTokenRolePermissionImpl implements StpInterface {


    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        return new ArrayList<>();
    }


    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        List<String> roles = new ArrayList<>();
        SaSession session = StpUtil.getSessionByLoginId(loginId);
        if (session != null && session.get("admin") != null) {
            roles.add("ADMIN");
        } else {
            roles.add("USER");
        }
        return roles;
    }
}